|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.realtime.AsyncEventHandler
An asychronous event handler encapsulates code that gets run at some time after
an AsyncEvent occurs.
It is essentially a java.lang.Runnable
with a set of parameter objects, making it
very much like a RealtimeThread.
The expectation is that there may be thousands
of events, with corresponding handlers, averaging about one handler per event. The
number of unblocked (i.e., scheduled) handlers is expected to be relatively small.
It is guaranteed that multiple firings of an event handler will be serialized. It
is also guaranteed that (unless the handler explicitly chooses otherwise) for each
firing of the handler, there will be one execution of the
handleAsyncEvent() method.
Instances of AsyncEventHandler
with a release parameter of type
SporadicParameters
have a list of release times which correspond to execution times of
AsyncEvent.fire().
The minimum interarrival time specified in
SporadicParameters is enforced as defined there.
Unless the handler explicitly chooses otherwise there will be one execution of the code
in handleAsyncEvent()
for each entry in the list. The i-th execution of
handleAsyncEvent() will be released for scheduling at the
time of the i-th entry in the list.
There is no restriction on what handlers may do. They may run for a long or short time, and they may block. (Note: blocked handlers may hold system resources.)
Normally, handlers are bound to an execution context dynamically, when their
AsyncEvent occurs.
This can introduce a (small) time penalty. For critical handlers
that can not afford the expense, and where this penalty is a problem, use a
BoundAsyncEventHandler.
The semantics for memory areas that were defined for realtime threads apply in
the same way to instances of
AsyncEventHandler. They may inherit a scope stack when
they are created, and the single parent rule applies to the use of memory scopes for
instances of AsyncEventHandler
just as it does in realtime threads.
| Field Summary | |
protected java.lang.Runnable |
logic
This object's logic |
protected MemoryArea |
memoryArea
This object's memory area |
protected MemoryParameters |
memoryParameters
This object's memory parameters |
protected boolean |
nonheap
Is does this run without a heap? |
protected int |
pendingFireCount
This object's pending fire count |
protected ProcessingGroupParameters |
processingGroup
This object's processing group parameters |
protected ReleaseParameters |
releaseParameters
The release parameters |
protected Scheduler |
scheduler
This object's scheduler |
protected SchedulingParameters |
schedulingParameters
The scheduling parameters |
| Constructor Summary | |
AsyncEventHandler()
Create a handler whose SchedulingParameters are inherited from the current
thread and does not have either
ReleaseParameters or
MemoryParameters. |
|
AsyncEventHandler(boolean nonheap)
Create a handler whose parameters are inherited from the current thread, if it is a RealtimeThread, or
null otherwise. |
|
AsyncEventHandler(boolean nonheap,
java.lang.Runnable logic)
Create a handler whose parameters are inherited from the current thread, if it is a RealtimeThread,
or null otherwise. |
|
AsyncEventHandler(java.lang.Runnable logic)
Create a handler whose SchedulingParameters are inherited from the current thread
and does not have either
ReleaseParameters or MemoryParameters. |
|
AsyncEventHandler(SchedulingParameters schedulingParameters,
ReleaseParameters releaseParameters,
MemoryParameters memoryParameters,
MemoryArea memoryArea,
ProcessingGroupParameters processingGroup,
boolean nonheap,
java.lang.Runnable logic)
Create a handler with the specified parameters. |
|
| Method Summary | |
boolean |
addIfFeasible()
Add to the feasibility of the associated scheduler if the resulting feasibility is schedulable. |
boolean |
addToFeasibility()
Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters,
ReleaseParameters,
MemoryParameters, and
ProcessingGroupParameters) of
this
instance of Schedulable will be considered
in the feasibility analysis of the
associated Scheduler until further notice. |
protected int |
getAndClearPendingFireCount()
Atomically set to zero the number of pending executions of this handler and return the value from before it was cleared. |
protected int |
getAndDecrementPendingFireCount()
Atomically decrements the number of pending executions of this handler (if it was non-zero) and returns the value from before the decrement. |
protected int |
getAndIncrementPendingFireCount()
Atomically increments the number of pending executions of this handler and returns the value from before the increment. |
MemoryArea |
getMemoryArea()
Get the current memory area. |
MemoryParameters |
getMemoryParameters()
Get this object' MemoryParameters. |
protected int |
getPendingFireCount()
|
ProcessingGroupParameters |
getProcessingGroupParameters()
|
ReleaseParameters |
getReleaseParameters()
Get the release parameters associated with this handler. |
Scheduler |
getScheduler()
Return the Scheduler for this handler. |
SchedulingParameters |
getSchedulingParameters()
Returns a reference to the scheduling parameters object. |
void |
handleAsyncEvent()
If this handler was constructed using a separate Runnable object, then
that Runnable object's run() method is called. |
boolean |
removeFromFeasibility()
Not currently implemented |
void |
run()
Not currently implemented |
boolean |
setIfFeasible(ReleaseParameters release,
MemoryParameters memoryParameters)
Not currently implemented |
void |
setMemoryParameters(MemoryParameters memoryParameters)
Set the MemoryParameters of this
schedulable object. |
boolean |
setMemoryParametersIfFeasible(MemoryParameters memory)
Not currently implemented |
void |
setProcessingGroupParameters(ProcessingGroupParameters processingGroup)
Set the ProcessingGroupParameters of this
schedulable object. |
boolean |
setProcessingGroupParametersIfFeasible(ProcessingGroupParameters groupParameters)
Not currently implemented |
void |
setReleaseParameters(ReleaseParameters releaseParameters)
Set the ReleaseParameters of
this object |
boolean |
setReleaseParametersIfFeasible(ReleaseParameters releaseParameters)
Not currently implemented |
void |
setScheduler(Scheduler scheduler)
Set the Scheduler of
this object |
void |
setScheduler(Scheduler scheduler,
SchedulingParameters schedulingParameters,
ReleaseParameters releaseParameters,
MemoryParameters memoryParameters,
ProcessingGroupParameters processingGroup)
Set the Scheduler and associated
parameters of this object |
void |
setSchedulingParameters(SchedulingParameters schedulingParameters)
Set the SchedulingParameters
of this object |
boolean |
setSchedulingParametersIfFeasible(SchedulingParameters schedulingParameters)
Not currently implemented |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected SchedulingParameters schedulingParameters
protected ReleaseParameters releaseParameters
protected MemoryParameters memoryParameters
protected MemoryArea memoryArea
protected ProcessingGroupParameters processingGroup
protected java.lang.Runnable logic
protected Scheduler scheduler
protected boolean nonheap
protected int pendingFireCount
| Constructor Detail |
public AsyncEventHandler()
SchedulingParameters are inherited from the current
thread and does not have either
ReleaseParameters or
MemoryParameters.
public AsyncEventHandler(boolean nonheap)
throws java.lang.IllegalArgumentException
RealtimeThread, or
null otherwise.
nonheap - A flag meaning, when true, that this will have characteristics
identical to a
NoHeapRealtimeThread. A false value means that this will have
characteristics identical to a
RealtimeThread. If true and the current
thread is not a
NoHeapRealtimeThread or a
RealtimeThread executing
within a ScopedMemory or
ImmortalMemory scope then an
IllegalArgumentException is thrown.
public AsyncEventHandler(boolean nonheap,
java.lang.Runnable logic)
throws java.lang.IllegalArgumentException
RealtimeThread,
or null otherwise.
nonheap - A flag meaning, when true, that this will have characteristics
identical to a NoHeapRealtimeThread.
A false value means this will have
characteristics identical to a
RealtimeThread.
If true and the current thread
is not a NoHeapRealtimeThread
or a
RealtimeThread executing within a
ScopedMemory
or ImmortalMemory scope then an
IllegalArgumentException
is thrownlogic - The java.lang.Runnable
object whose run is executed by handleAsyncEvent.public AsyncEventHandler(java.lang.Runnable logic)
SchedulingParameters are inherited from the current thread
and does not have either
ReleaseParameters or MemoryParameters.
logic - The java.lang.Runnable object whose run()
is executed by handleAsyncEvent().
public AsyncEventHandler(SchedulingParameters schedulingParameters,
ReleaseParameters releaseParameters,
MemoryParameters memoryParameters,
MemoryArea memoryArea,
ProcessingGroupParameters processingGroup,
boolean nonheap,
java.lang.Runnable logic)
throws java.lang.IllegalArgumentException
schedulingParameters - A SchedulingParameters
of the current thread.releaseParameters - A
ReleaseParameters
object which will be associated with
the constructed instance of this. If null this will have no
ReleaseParameters.memoryParameters - A MemoryParameters
object which will be associated with
the constructed instace of this. If null this will have no
MemoryParameters.memoryArea - The MemoryArea
for this AsyncEventHandler.
If null, inherit
the current memory area at the time of construction. The initial memory area
must be a reference to a ScopedMemory
or ImmortalMemory object if noheap is true.processingGroup - A
ProcessingGroupParameters object to which this will be
associated. If null this will not be associated with any processing group.nonheap - A flag meaning, when true, that this will have characteristics
identical to a NoHeapRealtimeThread.logic - The java.lang.Runnable object whose
run() is executed
by handleAsyncEvent().
IllegalArgumentException - if the initial memory area is in heap memory, and
the noheap parameter is true.
java.lang.IllegalArgumentException| Method Detail |
public boolean addIfFeasible()
Not currently implemented
public boolean addToFeasibility()
SchedulingParameters,
ReleaseParameters,
MemoryParameters, and
ProcessingGroupParameters) of
this
instance of Schedulable will be considered
in the feasibility analysis of the
associated Scheduler until further notice.
Whether the resulting system is feasible or not, the addition is completed.Not currently implemented
addToFeasibility in interface Schedulableprotected final int getAndClearPendingFireCount()
public void handleAsyncEvent() {
int fireCount = getAndClearPendingFireCount();
... handle the events ...
}
protected int getAndDecrementPendingFireCount()
public void handleAsyncEvent() {
int fireCount = getAndDecrementPendingFireCount();
... handle the events ...
}
The construction is necessary only in the case where one wishes to avoid
the setup costs since the framework guarantees that handleAsyncEvent() will be
invoked the appropriate number of times.
protected int getAndIncrementPendingFireCount()
handleAsyncEvent()
method does not need to do this, since the surrounding framework guarantees
that the handler will be re-executed the appropriate number of times.
It is only of value when there is a common setup code that is expensive.
public MemoryArea getMemoryArea()
public MemoryParameters getMemoryParameters()
MemoryParameters.
getMemoryParameters in interface Schedulableprotected final int getPendingFireCount()
public ProcessingGroupParameters getProcessingGroupParameters()
getProcessingGroupParameters in interface SchedulableProcessingGroupParameters of this objectpublic ReleaseParameters getReleaseParameters()
getReleaseParameters in interface Schedulablepublic Scheduler getScheduler()
Scheduler for this handler.
getScheduler in interface SchedulableScheduler
managing this.public SchedulingParameters getSchedulingParameters()
getSchedulingParameters in interface SchedulableSchedulingParameters object associated with this.public void handleAsyncEvent()
Runnable object, then
that Runnable object's run() method is called.
This method will be
invoked repeatedly while fireCount is greater than zero.
public boolean removeFromFeasibility()
removeFromFeasibility in interface Schedulablepublic final void run()
run in interface java.lang.Runnable
public boolean setIfFeasible(ReleaseParameters release,
MemoryParameters memoryParameters)
release - memoryParameters -
public void setMemoryParameters(MemoryParameters memoryParameters)
SchedulableMemoryParameters of this
schedulable object.
setMemoryParameters in interface SchedulablememoryParameters - public boolean setMemoryParametersIfFeasible(MemoryParameters memory)
setMemoryParametersIfFeasible in interface Schedulablememory -
public void setProcessingGroupParameters(ProcessingGroupParameters processingGroup)
SchedulableProcessingGroupParameters of this
schedulable object.
setProcessingGroupParameters in interface SchedulableprocessingGroup - public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters groupParameters)
setProcessingGroupParametersIfFeasible in interface SchedulablegroupParameters -
public void setReleaseParameters(ReleaseParameters releaseParameters)
SchedulableReleaseParameters of
this object
setReleaseParameters in interface SchedulablereleaseParameters - public boolean setReleaseParametersIfFeasible(ReleaseParameters releaseParameters)
setReleaseParametersIfFeasible in interface SchedulablereleaseParameters -
public void setScheduler(Scheduler scheduler)
throws java.lang.IllegalThreadStateException
SchedulableScheduler of
this object
setScheduler in interface Schedulablescheduler -
IllegalThreadStateException
java.lang.IllegalThreadStateException
public void setScheduler(Scheduler scheduler,
SchedulingParameters schedulingParameters,
ReleaseParameters releaseParameters,
MemoryParameters memoryParameters,
ProcessingGroupParameters processingGroup)
throws java.lang.IllegalThreadStateException
SchedulableScheduler and associated
parameters of this object
setScheduler in interface Schedulablescheduler - schedulingParameters - releaseParameters - memoryParameters - processingGroup -
java.lang.IllegalThreadStateExceptionpublic boolean setSchedulingParametersIfFeasible(SchedulingParameters schedulingParameters)
setSchedulingParametersIfFeasible in interface SchedulableschedulingParameters - the given
SchedulingParameters
public void setSchedulingParameters(SchedulingParameters schedulingParameters)
SchedulableSchedulingParameters
of this object
setSchedulingParameters in interface SchedulableschedulingParameters -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||